import 'package:base_flutter/base_flutter.dart';
import 'package:ls_work/message/message_config.dart';
class MedicalAdviceManageViewModel extends BaseViewModel{
  MedicalAdviceManageViewModel(super.context);

  ///长者姓名 / 房间号
  static String? searchName;

  static String? roomName;
  ///就诊卡号
  static String? cardNo;
  ///就诊卡号
  static String? prescriptionCode;
  ///医生
  static String? doctor;
  ///处方日期
  static String? prescriptionDate;

  void resetClick() {
    reset();
    notifyListeners();
    requestRefresh();

  }

  void reset(){
    searchName = null;
    cardNo = null;
    prescriptionCode = null;
    doctor = null;
    prescriptionDate = null;
    roomName = null;
  }

  void requestRefresh(){
    sendMessage(SendMessageEvent(MessageConfig.REFRESH_MEDICAL));
  }

  void chooseDate(){
    var format = [yyyy,'-',mm,'-',dd];
    DatePicker.showDatePicker(context,currentTime: prescriptionDate?.toDate(),onConfirm: (date){
      prescriptionDate = date!.toDateStr(format);
      notifyListeners();
      requestRefresh();
    });
  }

  @override
  void dispose() {
    super.dispose();
    reset();
  }
}